|
|
|
| |
|
|
|
|
Throughout this chapter, you use the SQL-VB5 program to create and run SQL scripts. The lesson on Day 13, "Creating Databases with SQL," contains a short tutorial on where to locate the SQL-VB5 program and how to use it. If you have not worked through the lesson on Day 13 yet, now is a good time to review at least the first half of that chapter. |
|
|
|
|
|
|
|
|
|
|
Data Manipulation SQL Keywords |
|
|
|
|
|
|
|
|
The Data Manipulation Language (DML) SQL keywords are used to add new data to existing tables, edit existing table data, append data from one table to another, copy data from one table to an entirely new table, and delete data rows from existing tables. |
|
|
|
|
|
|
|
|
Most of the time, your Visual Basic programs use data-entry screens to perform these tasks. However, sometimes the DML keywords come in handy. In some back-end database systems, these SQL keywords are the only way you can add, edit, or delete data from tables. At other times, these SQL keywords give you the power to produce updates to large tables with very few lines of code and in a relatively short amount of time. |
|
|
|
|
|
|
|
|
Also, many times you might need to select a small subset of data from your tables for a report or a graphic display. Instead of creating Dynaset views of existing tables, you might want to create a frozen Snapshot of the data to use for this purpose. What you need to do is copy some records from an existing table into a new table for use in reporting and displays. SQL DML keywords can help create these select tables quickly without extensive Visual Basic code. |
|
|
|
|
|
|
|
|
Another example of using SQL DML keywords is when you want to append a set of records from one table to another. Instead of writing Visual Basic code routines that read a record from one table and then write it to another, you can use SQL DML keywords to perform the table updatemany times with just one line of SQL code. |
|
|
|
|
|
|
|
|
Finally, SQL DML keywords allow you to quickly delete entire tables or subsets of data in a single SQL statement. This reduces the amount of Visual Basic code you need to write and also greatly speeds the processing in most cases. |
|
|
|
|
|
|
|
|
Adding Rows with the INSERT Statement |
|
|
|
|
|
|
|
|
The INSERT statement is used to insert values into data tables. You can use the INSERT statement to populate data tables automaticallywithout the need for data-entry screens. Also, you can perform this automatic data entry using very little Visual Basic code. |
|
|
|
|
|